<template>
  <div class="global_order marginTop10">
    <div class="main_white padding10 paddingTop0">
      <div class="main_ti">
        <el-tabs v-model="activeName" lazy @tab-click="handleClick">
          <el-tab-pane label="打印模板" name="0"></el-tab-pane>
          <el-tab-pane
            label="打印机配置"
            name="1"
            :disabled="taggleState"
          ></el-tab-pane>
        </el-tabs>

        <div class="mainua_form marginTop20">
          <div v-if="activeName == 0">
            <global-print
              ref="globalPrint"
              :tableData="tableData"
            ></global-print>
          </div>
          <div v-if="activeName == 1">
            <global-print-mark :tableData="tableData"></global-print-mark>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { apiUrl, objKeySort, Md5 } from "@/utils/public";
import GlobalPrint from "@/views/global/globalPrint.vue";
import GlobalPrintMark from "./globalPrintMark.vue";
import { get_muban_list, reset_template } from "@/api/global/globalPrint";

export default {
  components: {
    GlobalPrint,
    GlobalPrintMark,
  },
  data() {
    return {
      // 菜单切换
      activeName: "0",
      tableData: [],
      taggleState: true,
      // 多模板管理赛选
      more_tem_list: ["配送单模板"],
    };
  },
  methods: {
    handleClick(tab, event) {
      if (tab.name == 0) {
        this.getmubanlist();
      }
    },
    // 加载模板列表
    getmubanlist() {
      let data = Object.assign(
        apiUrl().name
      );
      get_muban_list(data).then((res) => {
        if (res.errcode == 0) {
          res.list.map((e) => {
            if (this.more_tem_list.includes(e.tem_name)) {
              e.show_more_tem_list = true;
            } else {
              e.show_more_tem_list = false;
            }
          });

          this.tableData = res.list;
          this.$refs["globalPrint"].listLoading = false;
          this.taggleState = false;
        }
      });
    },
  },
  created() {
    this.getmubanlist();
  },
};
</script>
<style lang="scss" scoped>
@import "@/styles/variables.scss";

.global_order {
  margin: 0 15px 0 15px;
  .mainua_form {
    .mainua_an {
      /deep/.el-form-item__content {
        margin-left: 0px !important;
      }
      .reset {
        background: $subActive;
        color: $menuText;
        border-color: $subActive;

        &:hover,
        &:focus {
          border-color: $menuActiveText;
          color: $menuActiveText;
        }
      }
    }
  }
}

/deep/.el-tabs__item:focus.is-active.is-focus:not(:active) {
  box-shadow: none !important;
}
</style>
